home *** CD-ROM | disk | FTP | other *** search
- ;char read_char();
-
- EXTRN _memory_model:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _read_char
- _read_char proc near
- L1: mov ah,1 ;func to check for char
- int 16h ;find out next char
- jz L1 ;loop if no char
- or al,al ;is it extended?
- jz L6 ;read by DOS func if so
- sub ah,ah ;BIOS func to read key
- int 16h ;get the ASCII code
- cmp al,8 ;is it backspace?
- jne L2 ;jump ahead if not
- cmp ah,14 ;is it from backspc key?
- je l7 ;jump ahead if so
- jmp short L5 ;else make it 208
- L2: cmp al,9 ;is it tab?
- jne L3 ;jump ahead if not
- cmp ah,15 ;is it from tab key?
- je L7 ;jump ahead if so
- jmp short L5 ;else make it 209
- L3: cmp al,13 ;is it carriage return?
- jne L4 ;jump ahead if not
- cmp ah,28 ;is it from CR key?
- je L7 ;jump ahead if so
- jmp short L5 ;else make it 213
- L4: cmp al,27 ;is it escape?
- jne L7 ;jump ahead if not
- cmp ah,1 ;is it from escape key?
- je L7 ;jump ahead if so
- L5: add al,200 ;inc key code by 200
- jmp short L7 ;go set char for return
- L6: mov ah,7 ;DOS keyboard read func
- int 21h ;get the initial 0
- L7: cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _read_char ENDP
- _TEXT ENDS
- END